package com.example.demotest.controllre.Impl;

import com.example.demotest.controllre.DeptController;
import com.example.demotest.javaBean.Result;
import com.example.demotest.javaBean.dept;
import com.example.demotest.service.Impl.addDeptServiceImpl;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:lele
 * @Date:2025/4/1
 */
//@RestController
@Controller
@ResponseBody
public class DeptControllerImpl implements DeptController {
    @Autowired
//            自动装配
    addDeptServiceImpl deptService;
    @GetMapping("/addinfo")
    @Override
    public String addController(String a) {
        String str = deptService.adddeptService("用户来请求了");
        return str;
    }
    @GetMapping("/dept")
    public Result List(){
        return Result.success(deptService.selectAllService());
    }
//删除
    @DeleteMapping("/dept/{id}")
    Result del(@PathVariable Integer id){
        deptService.delService(id);
        return Result.success();
    }
//    添加
    @PostMapping("/dept")
    Result addDeptController(@RequestBody dept dept){
        deptService.addService(dept);
        return Result.success();
    }
//得到一个数据
    @GetMapping("/dept/{id}")
     public Result getDateController(@PathVariable Integer id){
        dept dept=deptService.getService(id);
        return Result.success(dept);
    }
//    更新
    @PutMapping("/dept")
    Result updateController(@RequestBody dept dept){
        deptService.updataService(dept);
        return Result.success();
    }
//    登录
//    @PutMapping("/dept")


}
